<?php
require(dirname(__FILE__) . '/includes/init.php');
if(empty($_REQUEST['sn'])){
	header("Location: orders.php\n");
}else{
	$sql = "SELECT * FROM ".$ecs->table('orders')." WHERE order_id='".$_REQUEST['sn']."'";
	$order = $db->getRow($sql);
}
if ($_REQUEST['act'] == 'book')
{
	$order_id = intval($_REQUEST['order_id']);
	$sql = "SELECT * FROM ".$ecs->table('orders')." WHERE order_id='".$order_id."'";
	$order_id = $db->getOne($sql);
	if(empty($order_id)){
		header("Location: orders.php\n");
	}else{
		$sql = "SELECT order_id FROM ".$ecs->table('enrols')." WHERE order_id='".$order_id."'";
	    $order_id1 = $db->getOne($sql);
		if($order_id1){
			//sys("已经登记");
			header("Location: customerservice.php\n");
		}
		$question_cat = $_REQUEST['question_cat'];
        $descr = $_REQUEST['descr'];
		$qq = $_REQUEST['qq'];
		$enrol_name = $_REQUEST['enrol_name'];
		$sql = "INSERT INTO " .$ecs->table('enrols'). "(order_id,question_cat,descr,qq,enrol_time,enrol_name)".
                "VALUES ('".$order_id."', '".$question_cat."','".$descr."','".$qq."','".gmtime()."','".$enrol_name."')";
        $db->query($sql);
		header("Location: customerservice.php\n");
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>管理中心 - 处理登记 </title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles/general.css" rel="stylesheet" type="text/css" />
<link href="styles/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/common.js"></script>
</head>
<body>
 
<h1>
<span class="action-span"><a href="orders.php">订单列表</a></span>
<span class="action-span1"><a href="index.php?act=main">管理中心</a> </span><span id="search_id" class="action-span1"> - 处理登记 </span>
<div style="clear:both"></div>
</h1> 
<!-- start goods form -->
<div class="tab-div">
    <!-- tab bar -->
 
    <!-- tab body -->
    <div id="tabbody-div">
	  <table>
	    <tr>
		  <td>收货人：<?php echo $order['user'];?></td>
        </tr>
		 <tr>
		  <td>手机号：<?php echo $order['mobile'];?></td>
        </tr>
		 <tr>
		  <td>产品：<?php echo $order['product_name'];?></td>
        </tr>
	  </table>
      <form enctype="multipart/form-data" action="" method="post" name="theForm" onsubmit="return enrol_yz()">
        <table width="50%" id="general-table" align="center">
          <tr>
            <td class="label">问题类型：</td>
            <td><select name="question_cat" id="question_cat">
			<option value="0">请选择...</option>
			<option value="1">碎酒</option>
			<option value="2">漏发</option>
			<option value="3">发票</option>
			<option value="4">地址不对</option>
			<option value="5">其他</option>
			</select>
            </td>
          </tr>
		   <tr>
            <td class="label">登记人：</td>
            <td><select name="enrol_name" id="enrol_name">
			<option value="0">请选择...</option>
			<option value="曾平">曾平</option>
			<option value="郑娟">郑娟</option>
			<option value="张世杰">张世杰</option>
			<option value="唐志伟">唐志伟</option>
			<option value="张文强">张文强</option>
			<option value="林云川">林云川</option>
			</select>
          </tr>
          <tr>
            <td class="label">问题描述：</td>
            <td><textarea name="descr" cols="40" rows="3"></textarea></td>
          </tr>
		  <tr>
            <td class="label">联系QQ：</td>
            <td><input type="text" name="qq" value="" size="40" />可以不填</td>
          </tr>
		  <tr>
            <td><input type="hidden" name="order_id" value="<?php echo $_GET['sn'];?>" /></td>
          </tr>
        </table>
 
        <div class="button-div">
          <input type="hidden" name="goods_id" value="0" />
                    <input type="submit" value=" 确定 " class="button" />
          <input type="reset" value=" 重置 " class="button" />
        </div>
        <input type="hidden" name="act" value="book" />
      </form>
    </div>
</div>
<!-- end goods form -->
</body>
</html>
